#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
	int n;
	cin >> n;
	while (n--) {
		int count = 0;
		char arr[1000] = { '0' };
		cin >> arr;
		for (int i = 0; i < strlen(arr); i++) {
			if (arr[i] >= '0' && arr[i] <= '9') {
				count++;
			}
		}
		cout << count << endl;
	}
	return 0;
}